package com.xiaobai.zhuangxiuguanjia.activities;

import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.webkit.WebChromeClient;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.widget.ProgressBar;

import com.xiaobai.zhuangxiuguanjia.R;

public class ZxbActivity extends AppCompatActivity {

    private ProgressBar zxbProgress;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_zxb);

        ActionBar actionBar = getSupportActionBar();
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setTitle("申请装修保");

        zxbProgress = (ProgressBar) findViewById(R.id.zxb_progress);
        zxbProgress.setMax(100);

        WebView zxbWeb = (WebView) findViewById(R.id.zxb_webview);
        zxbWeb.setWebChromeClient(new WebChromeClient() {
            @Override
            public void onProgressChanged(WebView view, int newProgress) {
                if (newProgress == 100)
                    zxbProgress.setVisibility(View.GONE);
                else {
                    if (zxbProgress.getVisibility() == View.GONE)
                        zxbProgress.setVisibility(View.VISIBLE);

                    zxbProgress.setProgress(newProgress);
                }

                super.onProgressChanged(view, newProgress);
            }
        });
        zxbWeb.getSettings().setJavaScriptEnabled(true);
        zxbWeb.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
        zxbWeb.getSettings().setUseWideViewPort(true);
        zxbWeb.getSettings().setLoadWithOverviewMode(true);
        zxbWeb.loadUrl("http://m.to8to.com/company/zxb.php?to8to_from=yingyongbao&fromapp=app&pro_s_sourceid=1&device_src=3&ptag=30032_4_2_2");
    }
}
